package calculator.main;

public class TestMain {
	public static void test(Double val,Double expect) {
		if(val==null && expect!=null) {
			System.err.println("Test failed: expect "+expect+" value <null>");			
		}
		
		if(expect==null && val!=null) {
			System.err.println("Test failed: expect <null> value "+val);			
		}
		
		if(val!=null && !val.equals(expect)) {
			System.err.println("Test failed: expect "+expect+" value "+val);
		}
	}
	
	public static void main(String...args) {		
		test(CmdLineMain.evalOne("2"),2.0);
		test(CmdLineMain.evalOne("(2)"),2.0);
		test(CmdLineMain.evalOne("2+2"),4.0);
		test(CmdLineMain.evalOne("2+3+4"),9.0);
		test(CmdLineMain.evalOne("2+3*4-1"),13.0);
		test(CmdLineMain.evalOne("2+3*(4-1)"),11.0);
		test(CmdLineMain.evalOne("2+3*(4-1)*("),null);	
		test(CmdLineMain.evalOne("2+3*(4-1)*()"),null);	
		test(CmdLineMain.evalOne("2+3*(4-1)*(3)"),29.0);	
		test(CmdLineMain.evalOne("2+3*(4-1)*(3+2)"),47.0);	
		test(CmdLineMain.evalOne("2+3*(4-1)*(3+-2)"),11.0);	
	}
}
